﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using NUnit.Framework;
using Timer = XcoAppSpaces.Core.Communication.Timer;

namespace test.XcoAppSpaces.Core.Communication
{
	[TestFixture]
	public class TimerTest
	{
		[Test]
		public void Timer_executes_and_disposes_correctly()
		{
			//Arrange
			int count = 0;
			int interval = 100;
			
			//Act
			var timer = new Timer(() => Interlocked.Increment(ref count), interval);
			Thread.Sleep(350);
			timer.Dispose();
			Thread.Sleep(200);

			//Assert
			Assert.That(count, Is.EqualTo(3));
		}
	}
}
